/**
 * @file    inf_74hc595.h
 * @author  yhy
 * @brief   74HC595移位寄存器头文件
 * @version 1.01
 * @date    2025-07-19
 *
 * @copyright Copyright (c) 2025
 *
 * @details
 * Change Logs:
 * Date           Author       Notes
 * 2025-07-19     yhy          the first version V1.00
 * 2025-11-06     yhy          修复了所有通道共享duty_cycle的问题   V1.01
 */
#ifndef __INF_74HC595_H__
#define __INF_74HC595_H__

#include "common_config.h"

#include <stdbool.h>
#include <stdint.h>

/**
 * @brief 74HC595通道枚举
 *
 */
typedef enum
{
    SR_74HC595_CHANNEL_0 = 0U,
    SR_74HC595_CHANNEL_1,
    SR_74HC595_CHANNEL_2,
    SR_74HC595_CHANNEL_3,
    SR_74HC595_CHANNEL_4,
    SR_74HC595_CHANNEL_5,
    SR_74HC595_CHANNEL_6,
    SR_74HC595_CHANNEL_7,
    SR_74HC595_CHANNEL_8,
    SR_74HC595_CHANNEL_9,
    SR_74HC595_CHANNEL_10,
    SR_74HC595_CHANNEL_11,
    SR_74HC595_CHANNEL_12,
    SR_74HC595_CHANNEL_13,
    SR_74HC595_CHANNEL_14,
    SR_74HC595_CHANNEL_15,
    SR_74HC595_CHANNEL_16,
    SR_74HC595_CHANNEL_17,
    SR_74HC595_CHANNEL_18,
    SR_74HC595_CHANNEL_19,
    SR_74HC595_CHANNEL_20,
    SR_74HC595_CHANNEL_21,
    SR_74HC595_CHANNEL_22,
    SR_74HC595_CHANNEL_23,
    SR_74HC595_CHANNEL_24,
    SR_74HC595_CHANNEL_25,
    SR_74HC595_CHANNEL_26,
    SR_74HC595_CHANNEL_27,
    SR_74HC595_CHANNEL_28,
    SR_74HC595_CHANNEL_29,
    SR_74HC595_CHANNEL_30,
    SR_74HC595_CHANNEL_31,
    SR_74HC595_CHANNEL_MAX,
} sr_74hc595_channel_e;

/**
 * @brief 74HC595状态枚举, 使能通道或禁用通道
 *
 */
typedef enum
{
    SR_74HC595_STATE_DISABLE = 0U, /*!< 禁用通道 */
    SR_74HC595_STATE_ENABLE  = 1U, /*!< 使能通道 */
    SR_74HC595_STATE_MAX,
} sr_74hc595_state_e;

result_e inf_74hc595_init(void);
result_e inf_74hc595_set_channel(sr_74hc595_channel_e channel, sr_74hc595_state_e state);
result_e inf_74hc595_set_duty(sr_74hc595_channel_e channel, int8_t duty);

#endif
